<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListSalesInquiryEntityTitle}"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:form prependId="false" rendered="#{loginBacking.viewAllSalesInquiry}">
                <p:panel header="#{bundle.ListSalesInquiryEntityTitle} all Sales Inquiries">
                    <p:messages />
                    <br />
                    <h:outputText escape="false" value="#{bundle.ListSalesInquiryEntityEmpty}" rendered="#{salesInquiryEntityController.items.rowCount==0}"/>
                    <h:panelGroup rendered="#{salesInquiryEntityController.items.rowCount > 0}">
                        <p:dataTable value="#{salesInquiryEntityController.items}" 
                                     var="item" style="table-layout:fixed"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">

                            <p:column filterBy="#{item.id}">
                                <f:facet name="header">
                                    <h:outputText value="Id"/>
                                </f:facet>
                                <h:outputText value="#{item.id}"/>
                            </p:column>

                            <p:column filterBy="#{item.salesLead.fullname}" filterMatchMode="contains">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListSalesInquiryEntityTitle_salesLead}"/>
                                </f:facet>
                                <h:outputText value="#{item.salesLead.firstName}&nbsp;#{item.salesLead.lastName}"/>
                            </p:column>

                            <p:column filterBy="#{item.customer.fullname}" filterMatchMode="contains">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListSalesInquiryEntityTitle_customer}"/>
                                </f:facet>
                                <h:outputText value="#{item.customer.firstName}&nbsp;#{item.customer.lastName}"/>
                            </p:column>

                            <p:column filterBy="#{item.createdBy.fullname}" filterMatchMode="contains">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListSalesInquiryEntityTitle_createdBy}"/>
                                </f:facet>
                                <h:outputText value="#{item.createdBy.firstName}&nbsp;#{item.createdBy.lastName}"/>
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListSalesInquiryEntityTitle_createdAt}"/>
                                </f:facet>
                                <h:outputText value="#{item.createdAt}">
                                    <f:convertDateTime pattern="dd/MM/yyyy" />
                                </h:outputText>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>
                                <p:commandButton image="ui-icon ui-icon-search" action="#{salesInquiryEntityController.prepareView}" ajax="false"/>
                            </p:column>

                            <p:column>
                                <p:menuButton value="Options"> 
                                    <p:menuitem action="#{salesInquiryEntityController.convert}" value="Convert" rendered="#{item.converted==false}" ajax="false" icon="ui-icon ui-icon-arrowrefresh-1-w" />
                                    <p:menuitem action="#{salesInquiryEntityController.destroy}" value="Delete" rendered="#{item.archived==false and salesInquiryEntityController.checkSystemUser()==true}" ajax="false" icon="ui-icon ui-icon-close"/>
                                </p:menuButton>
                            </p:column>
                        </p:dataTable>
                    </h:panelGroup>
                    <br />
                </p:panel>
                <p:commandButton action="#{salesInquiryEntityController.prepareCreate}" value="New Inquiry" ajax="false"/>
                &nbsp;
                <p:commandButton value="Search Sales Inquiry" action="#{salesInquiryEntityController.prepareSearchForm}" ajax="false"/>
                <br />
            </h:form>
        </ui:define>
    </ui:composition>

</html>
